/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.recorder.video;

import java.awt.image.BufferedImage;
import java.io.IOException;

import fr.uha.ensisa.jmp.drone.recorder.FileRecorder;
import fr.uha.ensisa.jmp.drone.recorder.FileWriter;
import fr.uha.ensisa.jmp.drone.video.ImageConsumer;


public class VideoRecorder extends FileRecorder<BufferedImage> implements ImageConsumer
{

	public VideoRecorder(FileWriter<BufferedImage> writer)
	{
		super(writer);
	}
	
	public VideoRecorder(FileWriter<BufferedImage> writer, String directory)
	{
		super(writer, directory, null);
	}

	@Override
	public void consume(BufferedImage image)
	{
		try
		{
			this.record(image);
		}
		catch (IOException e)
		{
			e.printStackTrace();
			try
			{
				this.stop();
			}
			catch (IOException e1)
			{
				e1.printStackTrace();
			}
		}

	}
}
